package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.ExperienceVO;
import com.digitalchina.lxnsy.interfaces.IMyNhbPos;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/8/6 11:10
 * 修改备注：
 * ================================================
 */

public class MyExperienceListHolder extends BaseViewHolder<ExperienceVO> {

    private TextView tvName;
    private TextView tvTitle;
    private TextView tvAddress;
    private TextView tvPraise;
    private TextView tvEdit;
    private TextView tvDel;
    private LinearLayout layout;

    private IMyNhbPos iMyNhbPos;


    public MyExperienceListHolder(ViewGroup parent,IMyNhbPos iMyNhbPos) {
        super(parent, R.layout.item_exp_list);
        tvName = $(R.id.tv_name);
        tvTitle = $(R.id.tv_title);
        tvAddress = $(R.id.tv_address);
        tvPraise = $(R.id.tv_praise);
        tvEdit = $(R.id.tv_edit);
        tvDel = $(R.id.tv_del);
        layout = $(R.id.layout);

        this.iMyNhbPos = iMyNhbPos;
    }

    @Override
    public void setData(ExperienceVO data) {
        super.setData(data);

        layout.setVisibility(View.VISIBLE);

        tvName.setText(data.getUserName());
        tvTitle.setText(data.getTitle());
        tvAddress.setText(data.getGeographicalPosition());
        tvPraise.setText(data.getPraiseNum()+"赞同");

        tvEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                iMyNhbPos.edit(getAdapterPosition());
            }
        });

        tvDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                iMyNhbPos.del(getAdapterPosition());
            }
        });
    }

}
